package com.hctforgreen.greenservice.utils;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

/**
 * wifi自动更新 存储Util
 *
 * @author denghb
 */
public class WifiFreshStateStoreUtil {

    /**
     * 保存wifi自动更新状态
     *
     * @param context
     * @param state
     */
    public static void save(Context context, boolean state) {
        SharedPreferences sharedPreferences = context.getSharedPreferences(
                HctConstants.WIFI_FRESH_STATE_FILE_NAME,
                Context.MODE_WORLD_WRITEABLE);
        Editor editor = sharedPreferences.edit();
        editor.putBoolean(HctConstants.WIFI_FRESH_STATE_KEY_VALUE, state);
        editor.commit();
    }

    /**
     * 自动更新状态
     *
     * @param context
     * @return 是否自动更新
     */
    public static boolean get(Context context) {
        SharedPreferences sharedPreferences = context.getSharedPreferences(
                HctConstants.WIFI_FRESH_STATE_FILE_NAME,
                Context.MODE_WORLD_WRITEABLE);
        return sharedPreferences.getBoolean(
                HctConstants.WIFI_FRESH_STATE_KEY_VALUE, true);
    }

}
